package cn.mavor.day0910.Company;

import java.util.ArrayList;
import java.util.List;

public class Company {
    private String name; // 公司名称
    private String address; // 注册地址
    private String phone; // 电话
    private String businessScope; // 经营范围
    private List<Employee> employees; // 员工列表

    public Company(String name, String address, String phone, String businessScope) {
        this.name = name;
        this.address = address;
        this.phone = phone;
        this.businessScope = businessScope;
        this.employees = new ArrayList<>();
    }

    // 招聘员工方法
    public boolean hireEmployee(Employee employee) {
        for (Employee e : employees) {
            if (e.getEmployeeId().equals(employee.getEmployeeId())) {
                return false; // 工号重复
            }
        }
        employees.add(employee);
        return true;
    }

    // 辞退员工方法
    public boolean fireEmployee(String employeeId) {
        for (int i = 0; i < employees.size(); i++) {
            if (employees.get(i).getEmployeeId().equals(employeeId)) {
                employees.remove(i);
                return true;
            }
        }
        return false;
    }

    // 输出所有员工信息方法
    public void printEmployees() {
        for (Employee employee : employees) {
            System.out.println(employee);
        }
    }

    // 获取公司员工人数方法
    public int getNumberOfEmployees() {
        return employees.size();
    }

    // 获取公司薪水最高的员工方法
    public Employee getHighestPaidEmployee() {
        if (employees.isEmpty()) {
            return null;
        }
        Employee highestPaid = employees.get(0);
        for (Employee employee : employees) {
            if (employee.getSalary() > highestPaid.getSalary()) {
                highestPaid = employee;
            }
        }
        return highestPaid;
    }

    // Getter 和 Setter 方法
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public String getAddress() { return address; }
    public void setAddress(String address) { this.address = address; }
    public String getPhone() { return phone; }
    public void setPhone(String phone) { this.phone = phone; }
    public String getBusinessScope() { return businessScope; }
    public void setBusinessScope(String businessScope) { this.businessScope = businessScope; }
}